package com.aierkeji.b2c.entity;

import java.math.BigDecimal;
import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.aierkeji.b2c.entity.snapshot.AkjAlipayLifeSnap;
import com.aierkeji.b2c.utils.WebUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 商品
 *
 * @author 陈宇强
 */
@Entity
@Table(name = "akj_product")
public class AkjProduct {
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    @Column(length = 32)
    private String id;

    @Column(length = 64)
    private String name;

    @Column(length = 512)
    private String descript;

    @ManyToOne(targetEntity = AkjFile.class, cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "img")
    @NotFound(action = NotFoundAction.IGNORE)
    private AkjFile img;

    @ManyToOne(targetEntity = AkjAuser.class, cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "create_by", nullable = true)
    @NotFound(action = NotFoundAction.IGNORE)
    private AkjAuser createBy;

    @Column
    private Timestamp createAt;


    @ManyToOne(targetEntity = AkjAuser.class, cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "update_by")
    @NotFound(action = NotFoundAction.IGNORE)
    private AkjAuser updateBy;

    @Column
    private Timestamp updateAt;

    @ManyToOne(targetEntity = AkjAlipayLifeSnap.class, cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "alipay_life_id")
    private AkjAlipayLifeSnap akjAlipayLifeSnap;

    @Column(name = "is_delete")
    private Boolean delete;

    @Column(precision = 10,scale = 2)
    private BigDecimal price;
    
    @Column(name="activation_time")
    private Long activationTime;//可激活时长


    public AkjProduct() {
        super();
    }

    public AkjProduct(String id, String name) {
        super();
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    public AkjFile getImg() {
        return img;
    }

    public void setImg(AkjFile img) {
        this.img = img;
    }

    public AkjAuser getCreateBy() {
        return createBy;
    }

    public void setCreateBy(AkjAuser createBy) {
        this.createBy = createBy;
    }

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    public Timestamp getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Timestamp createAt) {
        this.createAt = createAt;
    }

    public AkjAlipayLifeSnap getAkjAlipayLifeSnap() {
		return akjAlipayLifeSnap;
	}

	public void setAkjAlipayLifeSnap(AkjAlipayLifeSnap akjAlipayLifeSnap) {
		this.akjAlipayLifeSnap = akjAlipayLifeSnap;
	}

	public AkjAuser getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(AkjAuser updateBy) {
        this.updateBy = updateBy;
    }

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    public Timestamp getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Timestamp updateAt) {
        this.updateAt = updateAt;
    }

    public Boolean getDelete() {
        return delete;
    }

    public void setDelete(Boolean delete) {
        this.delete = delete;
    }

    public Boolean checkParamsNull() {
        return WebUtils.checkParamsIsNull(this.descript, this.name, this);
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

	public Long getActivationTime() {
		return activationTime;
	}

	public void setActivationTime(Long activationTime) {
		this.activationTime = activationTime;
	}
    
    
}
